#include "Cats/CatStates/CatState.h"
#include "Cats/CatStates/CatState_Punk_Skill.h"
#include "Cats/CatSpriteLoader.h"
#include "Cats/BaseCat.h"
#include "Character/Character.h"
#include "Map/GameMap.h"

CatState_Punk_Skill::CatState_Punk_Skill(BaseCat* pCatRef):CatState(pCatRef)
{
	_exitState = false;
}

CatState_Punk_Skill::~CatState_Punk_Skill()
{

}

void CatState_Punk_Skill::runOnEnter()
{
	//do not exit state yet
	_exitState = false;

	//store the duration of the animation
	_summonAnimationDuration = CatSpriteLoader::getAnimationDuration(_pCatRef->getCatType(), CAT_ANIM_SKILL);
	_pCatRef->stopAllActions();
	_pCatRef->runAction(CatSpriteLoader::getCatAnimation(_pCatRef->getCatType(), CAT_ANIM_SKILL));
}

void CatState_Punk_Skill::update(float timeDiff)
{
	_summonAnimationDuration -= timeDiff;

	//animation completed
	if (!_exitState && _summonAnimationDuration <= 0) //guard against on resume
	{
		_exitState = true;
	}

	if (_exitState)
	{
		//enter chasing state
		_pCatRef->setNextCatState(CAT_CHASE);
	}
}

void CatState_Punk_Skill::onExit()
{
	CatState::onExit();
	_pCatRef->stopAllActions();
}

void CatState_Punk_Skill::onPause()
{
	CatState::onPause();
	_exitState = true;
}
